﻿<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ page import="com.qingke.blog.pojo.Article"%>
<%@ page import="com.qingke.blog.pojo.User"%>
<%@ page import="com.qingke.blog.dao.BlogDAO"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Striped</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link
	href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400italic,700|Open+Sans+Condensed:300,700"
	rel="stylesheet" />
<script src="js/jquery-1.8.3.min.js"></script>
<script src="js/blog.js"></script>
<script
	src="css/5grid/init.js?use=mobile,desktop,1200px,1000px&amp;mobileUI=1&amp;mobileUI.theme=none"></script>
<noscript>
	<link rel="stylesheet" href="css/5grid/core.css" />
	<link rel="stylesheet" href="css/5grid/core-desktop.css" />
	<link rel="stylesheet" href="css/5grid/core-1200px.css" />
	<link rel="stylesheet" href="css/5grid/core-noscript.css" />
	<link rel="stylesheet" href="css/style.css" />
	<link rel="stylesheet" href="css/style-desktop.css" />
	<link rel="stylesheet" href="css/style-1200px.css" />
</noscript>

</head>
<%
	User user = (User) session.getAttribute("user");
%>
<body class="left-sidebar">

	<!-- Wrapper -->

	<div id="wrapper">

		<!-- Content -->
		<div id="content" class="mobileUI-main-content">
			<div id="content-inner">
				<%
					BlogDAO dao = new BlogDAO();
					List<Article> list = dao.listAllArticle();
					if (list != null) {
						for (Article a : list) {
							File file = new File("D:/workspace/Blog/WebContent/article/" + a.getContentPath());
							BufferedReader br = new BufferedReader(new FileReader(file));
							List<String> lines = new ArrayList<>();
							String line = null;
							while ((line = br.readLine()) != null) {
								lines.add(line);
							}
							br.close();
				%>
				<article class="is-post is-post-excerpt"> <header>
				<h2>
					<a href="#"><%=a.getArticleName()%></a>
				</h2>
				<span class="byline"></span> </header>
				<div class="info">
					<span class="date"><span class="month"><%=a.getMonth()%><span>uary</span></span>
						<span class="day"><%=a.getDate()%></span> <span class="year"><%=a.getYear()%></span></span>
					<ul class="stats">
						<li><a class="link-icon24 link-icon24-2"
							id="likeArticle<%=a.getId()%>"
							onclick="likeArticle(<%=a.getId()%>,<%=user == null ? 0 : user.getId()%>)"><%=dao.selectLikeByArticleId(a.getId())%></a></li>
						<li><a class="link-icon24 link-icon24-3"
							id="dislikeArticle<%=a.getId()%>"
							onclick="dislikeArticle(<%=a.getId()%>,<%=user == null ? 0 : user.getId()%>)"><%=dao.selectDislikeByArticleId(a.getId())%></a></li>
						<%
							if (user != null && a.getUserId() == user.getId()) {
						%>
						<li><button onclick="edit(<%=a.getId()%>)">编辑</button></li>
						<%
							}
						%>
					</ul>
				</div>
				<a href="#" class="image image-full"><img src="" alt="" /></a> <%
 	for (String l : lines) {
 %>
				<p><%=l%></p>
				<%
					}
				%> </article>
				<%
					}
					}
				%>
				<!-- Pager -->
				<div class="pager">
					<!--<a href="#" class="button previous">Previous Page</a>-->
					<div class="pages">
						<a href="#" class="active">1</a> <a href="#">2</a> <a href="#">3</a>
						<a href="#">4</a> <span>&hellip;</span> <a href="#">20</a>
					</div>
					<a href="#" class="button next">Next Page</a>
				</div>

			</div>
		</div>

		<!-- Sidebar -->
		<div id="sidebar">

			<!-- Logo -->
			<div id="logo">
				<%
					if (user == null) {
				%>
				<button id="login" onclick="window.location.href='login.html'">登录</button>
				<button id="register" onclick="window.location.href='register.html'">注册</button>
				<%
					} else {
				%>
				<h1 id="nickname" class="mobileUI-site-name"><%=user.getNickname()%></h1>
				<br>
				<button id="write" onclick="window.location.href='write.html'">写文章</button>
				<button id="quit" onclick="quit()">退出</button>
				<%
					}
				%>

			</div>


			<!-- Nav -->
			<nav id="nav" class="mobileUI-site-nav">
			<ul>
				<li class="current_page_item"><a href="#">Latest Post</a></li>
				<li><a href="#">Archives</a></li>
				<li><a href="#">About Me</a></li>
				<li><a href="#">Contact Me</a></li>
			</ul>
			</nav>

			<!-- Search -->
			<section class="is-search is-first">
			<form method="post" action="#">
				<input type="text" class="text" name="search" placeholder="Search" />
			</form>
			</section>

			<!-- Text -->
			<section class="is-text-style1">
			<div class="inner">
				<p></p>
			</div>
			</section>

			<!-- Recent Posts -->
			<section class="is-recent-posts"> <header>
			<h2>Recent Posts</h2>
			</header>
			<ul>
				<li><a href="#">Nothing happened</a></li>
				<li><a href="#">My Dearest Cthulhu</a></li>
				<li><a href="#">The Meme Meme</a></li>
				<li><a href="#">Now Full Cyborg</a></li>
				<li><a href="#">Temporal Flux</a></li>
			</ul>
			</section>

			<!-- Recent Comments -->
			<section class="is-recent-comments"> <header>
			<h2>Recent Comments</h2>
			</header>
			<ul>
				<li>case on <a href="#">Now Full Cyborg</a></li>
				<li>molly on <a href="#">Untitled Post</a></li>
				<li>case on <a href="#">Temporal Flux</a></li>
			</ul>
			</section>

			<!-- Calendar -->
			<section class="is-calendar">
			<div class="inner">
				<table>
					<caption>February 2013</caption>
					<thead>
						<tr>
							<th scope="col" title="Monday">M</th>
							<th scope="col" title="Tuesday">T</th>
							<th scope="col" title="Wednesday">W</th>
							<th scope="col" title="Thursday">T</th>
							<th scope="col" title="Friday">F</th>
							<th scope="col" title="Saturday">S</th>
							<th scope="col" title="Sunday">S</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td colspan="4" class="pad"><span>&nbsp;</span></td>
							<td><span>1</span></td>
							<td><span>2</span></td>
							<td><span>3</span></td>
						</tr>
						<tr>
							<td><span>4</span></td>
							<td><span>5</span></td>
							<td><a href="#">6</a></td>
							<td><span>7</span></td>
							<td><span>8</span></td>
							<td><span>9</span></td>
							<td><a href="#">10</a></td>
						</tr>
						<tr>
							<td><span>11</span></td>
							<td><span>12</span></td>
							<td><span>13</span></td>
							<td class="today"><a href="#">14</a></td>
							<td><span>15</span></td>
							<td><span>16</span></td>
							<td><span>17</span></td>
						</tr>
						<tr>
							<td><span>18</span></td>
							<td><span>19</span></td>
							<td><span>20</span></td>
							<td><span>21</span></td>
							<td><span>22</span></td>
							<td><a href="#">23</a></td>
							<td><span>24</span></td>
						</tr>
						<tr>
							<td><a href="#">25</a></td>
							<td><span>26</span></td>
							<td><span>27</span></td>
							<td><span>28</span></td>
							<td class="pad" colspan="3"><span>&nbsp;</span></td>
						</tr>
					</tbody>
				</table>
			</div>
			</section>

			<!-- Copyright -->
			<div id="copyright">
				<p>
					&copy; 2013 An Untitled Site <a target="_blank"
						href="http://www.huiyi8.com/moban/">网页模板</a>.
				</p>
			</div>

		</div>

	</div>

	<div style="display: none">
		<script src='http://v7.cnzz.com/stat.php?id=155540&web_id=155540'
			language='JavaScript' charset='gb2312'></script>
	</div>
</body>
</html>